<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Gbook2 extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'gbook2';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'manyi_text',
        'status_text'
    ];
    

    
    public function getManyiList()
    {
        return ['5' => __('Manyi 5'), '4' => __('Manyi 4'), '3' => __('Manyi 3'), '2' => __('Manyi 2'), '1' => __('Manyi 1'), '0' => __('Manyi 0')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }


    public function getManyiTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['manyi']) ? $data['manyi'] : '');
        $list = $this->getManyiList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
